// =================================================================
// File: seek.cpp
// Desc: Contains function for changing the seek offset of a file
// =================================================================

// =================================================================
// INCLUDES
// =================================================================

#include "FSManager.h"
#include "File.h"
#include "commands.h"

using namespace std;

// =================================================================
// FUNCTIONS
// =================================================================

// =================================================================
// Name: seek
// Desc: Changes the seek offset of the file associated with the given fd
// Args: int fd - the file descriptor of the file to seek in
//	 int offset - the amount of bytes to move the seek offset.
//       FSManager* fsm - pointer to active FSManager object
// Rets: -1 if the file does not exist, or 0 if the function was a success
// =================================================================

int seek(int fd, int offset, FSManager *fsm){

    File *file;

    file = fsm->GetOpenFile(fd);
    
    if(file == NULL)
        return -1;

    file->SetSeekOffset(offset);

    return 0;

}
